package com.android.presenter.info;

import com.android.model.entity.res.OrderCompletedResult;
import com.android.model.info.UserModel;
import com.android.model.net.HttpObserver;
import com.android.presenter.base.BasePresenter;
import com.android.presenter.iview.IOrderCompletedView;
import com.android.util.log.LogUtil;

/**
 * author:  TenFace
 * date:    2017/9/27
 * description: 完全成交和已经撤单
 */

public class CompletedOrderPresenter extends BasePresenter<IOrderCompletedView> {

    private static final String TAG = CompletedOrderPresenter.class.getSimpleName();
    private UserModel mUserModel;

    public CompletedOrderPresenter(IOrderCompletedView iOrderCompletedView) {
        super(iOrderCompletedView);
        mUserModel = UserModel.getInstance();
    }

    public void getListCompletedOrder(String accountId,
                                      int page,
                                      int limit,
                                      String token) {

        mUserModel.getListCompletedOrder(accountId, page, limit, token, new HttpObserver<OrderCompletedResult>() {
            @Override
            public void onSuccess(OrderCompletedResult orderResultList) {
                LogUtil.e(TAG, "成功！");
                if (mIView != null) {
                    mIView.orderCompletedSuccess(orderResultList);
                }
            }

            @Override
            public void onError(int errType, String errMessage) {
                LogUtil.e(TAG, "失败码：" + errType + "》》信息：" + errMessage);
                if (mIView != null) {
                    mIView.orderCompletedFail(errType, errMessage);
                }
            }
        }, mIView.getLifeSubject());
    }

}
